package com.hnichr.ump.school.service.impl;

import com.hnichr.ump.common.school.entity.Student;
import com.hnichr.ump.common.school.service.StudentService;
import com.mxpioframework.jpa.JpaUtil;
import com.mxpioframework.system.service.impl.BaseServiceImpl;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class StudentServiceimpl extends BaseServiceImpl<Student> implements StudentService {
    @Transactional(readOnly = true)
    public Student getByMobile(String mobile) {
        List<Student> cardList = JpaUtil.linq(Student.class).equal("mobile", mobile).list();
        if (CollectionUtils.isNotEmpty(cardList)) {
            return cardList.get(0);
        }
        return null;
    }

    /*@Transactional(readOnly = true)
    public Student getAnswer(String mobile) {
        List<Student> answerList = JpaUtil.linq(Student.class).select("answer").equal("mobile", mobile).list();
        if (CollectionUtils.isNotEmpty(answerList)) {
            return answerList.get(0);
        }
        return null;
    }*/
}
